package clients

import (
	"context"

	alertv1 "github.com/devops-smartbot/devops-smartbot/proto/gen/go/alert/v1"
	aiv1 "github.com/devops-smartbot/devops-smartbot/proto/gen/go/ai/v1"
	ticketv1 "github.com/devops-smartbot/devops-smartbot/proto/gen/go/ticket/v1"
	"google.golang.org/grpc"
)

// AlertClient defines the interface the gateway relies on.
type AlertClient interface {
	alertv1.AlertServiceClient
}

// AIClient defines the contract for AI analysis requests.
type AIClient interface {
	aiv1.AIGatewayClient
}

// TicketClient defines the interface for ticket service.
type TicketClient interface {
	ticketv1.TicketServiceClient
}

// DialAlertService constructs an Alert gRPC client.
func DialAlertService(ctx context.Context, addr string, opts ...grpc.DialOption) (AlertClient, error) {
	conn, err := grpc.DialContext(ctx, addr, opts...)
	if err != nil {
		return nil, err
	}
	return alertv1.NewAlertServiceClient(conn), nil
}

// DialAIService constructs an AI Gateway client.
func DialAIService(ctx context.Context, addr string, opts ...grpc.DialOption) (AIClient, error) {
	conn, err := grpc.DialContext(ctx, addr, opts...)
	if err != nil {
		return nil, err
	}
	return aiv1.NewAIGatewayClient(conn), nil
}

// DialTicketService constructs a Ticket gRPC client.
func DialTicketService(ctx context.Context, addr string, opts ...grpc.DialOption) (TicketClient, error) {
	conn, err := grpc.DialContext(ctx, addr, opts...)
	if err != nil {
		return nil, err
	}
	return ticketv1.NewTicketServiceClient(conn), nil
}
